<!doctype html>


<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>mockmatchers.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>





<div class="colmask rightmenu">
<div class="colleft">
    <div class="col1">
      <!-- Column 1 start -->

<div id="title">
       <span class="fn">mockmatchers.js</span>
</div>

<div class="g-section g-tpl-75-25">
  <div class="g-unit g-first" id="description">
    Matchers to be used with the mock utilities.  They allow for
 flexible matching by type.  Custom matchers can be created by passing a
 matcher function into an ArgumentMatcher instance.

 For examples, please see the unit test.
  </div>
  

        <div class="g-unit" id="useful-links">
          <div class="title">Useful links</div>
          <ol>
            <li><a href="closure_goog_testing_mockmatchers.js.source.html"><span class='source-code-link'>Source Code</span></a></li>
            <li><a href="http://code.google.com/p/closure-library/source/browse/closure/goog/testing/mockmatchers.js">Git</a></li>
          </ol>
        </div>
</div>

<h2 class="g-first">File Location</h2>
  <div class="g-section g-tpl-20-80">
    <div class="g-unit g-first">
      <div class="g-c-cell code-label">testing/mockmatchers.js</div>
    </div>
  </div>
<hr/>


  <h2>Classes</h2>
 <div class="fn-constructor">
        <a href="class_goog_testing_mockmatchers_ArgumentMatcher.html">
          goog.testing.mockmatchers.ArgumentMatcher</a><br/>
        <div class="class-details">A simple interface for executing argument matching.  A match in this case is
testing to see if a supplied object fits a given criteria.  True is returned
if the given criteria is met.</div>
 </div>
 <div class="fn-constructor">
        <a href="class_goog_testing_mockmatchers_IgnoreArgument.html">
          goog.testing.mockmatchers.IgnoreArgument</a><br/>
        <div class="class-details">A matcher that always returns true. It is useful when the user does not care
for some arguments.
For example: mockFunction('username', 'password', IgnoreArgument);</div>
 </div>
 <div class="fn-constructor">
        <a href="class_goog_testing_mockmatchers_InstanceOf.html">
          goog.testing.mockmatchers.InstanceOf</a><br/>
        <div class="class-details">A matcher that verifies that an argument is an instance of a given class.</div>
 </div>
 <div class="fn-constructor">
        <a href="class_goog_testing_mockmatchers_ObjectEquals.html">
          goog.testing.mockmatchers.ObjectEquals</a><br/>
        <div class="class-details">A matcher that verifies that the argument is an object that equals the given
expected object, using a deep comparison.</div>
 </div>
 <div class="fn-constructor">
        <a href="class_goog_testing_mockmatchers_RegexpMatch.html">
          goog.testing.mockmatchers.RegexpMatch</a><br/>
        <div class="class-details">A matcher that verifies that an argument matches a given RegExp.</div>
 </div>
 <div class="fn-constructor">
        <a href="class_goog_testing_mockmatchers_SaveArgument.html">
          goog.testing.mockmatchers.SaveArgument</a><br/>
        <div class="class-details">A matcher that saves the argument that it is verifying so that your unit test
can perform extra tests with this argument later.  For example, if the
argument is a callback method, the unit test can then later call this
callback to test the asynchronous portion of the call.</div>
 </div>
 <div class="fn-constructor">
        <a href="class_goog_testing_mockmatchers_TypeOf.html">
          goog.testing.mockmatchers.TypeOf</a><br/>
        <div class="class-details">A matcher that verifies that an argument is of a given type (e.g. "object").</div>
 </div>
      
<br/>

  <div class="legend">
        <span class="key publickey"></span><span>Public</span>
        <span class="key protectedkey"></span><span>Protected</span>
        <span class="key privatekey"></span><span>Private</span>
  </div>









<div class="section">
  <table class="horiz-rule">


  </table>
</div>




  <h2>Global Functions</h2>





<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.testing.mockmatchers.ArgumentMatcher.call"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.mockmatchers.ArgumentMatcher.</span><span class="entryName">call<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

   
  </td>


  <td class="view-code">
     <a href="closure_goog_testing_mockmatchers.js.source.html#line51">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.testing.mockmatchers.flexibleArrayMatcher"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.mockmatchers.</span><span class="entryName">flexibleArrayMatcher<span class="args">(<span class="arg">expectedArr</span>,&nbsp;<span class="arg">arr</span>,&nbsp;<span class="arg">opt_expectation</span>)</span>
        </span>
        &#8658; <div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span></div>
      </div>


     <div class="entryOverview">
       A function that checks to see if an array matches a given set of
expectations.  The expectations array can be a mix of ArgumentMatcher
implementations and values.  True will be returned if values are identical or
if a matcher returns a positive result.
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">expectedArr</span>
        : <div class="fullType">(<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span>)</div>
        <div class="entryOverview">An array of expectations which can be either values to check for equality or ArgumentMatchers.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">arr</span>
        : <div class="fullType">(<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span>)</div>
        <div class="entryOverview">The array to match.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_expectation</span>
        : <div class="fullType">(<span class="type"><a href="class_goog_testing_MockExpectation.html">goog.testing.MockExpectation</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span><span>&nbsp;|&nbsp;</span><span class="type">undefined</span>)</div>
        <div class="entryOverview">The expectation for this match.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<div class="fullType"><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span></div>&nbsp;
            Whether or not the given array matches the expectations.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="closure_goog_testing_mockmatchers.js.source.html#line364">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>



  <h2>Global Properties</h2>





<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>





  <a name="goog.testing.mockmatchers.ignoreArgument"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.mockmatchers.</span><span class="entryName">ignoreArgument</span>
        : <div class="fullType">(<span class="type"><a href="class_goog_testing_mockmatchers_IgnoreArgument.html">goog.testing.mockmatchers.IgnoreArgument</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span>)</div>
     </div>


     <div class="entryOverview">
       An instance of the IgnoreArgument matcher. Returns true for all matches.
     </div>

  </td>


  <td class="view-code">
     <a href="closure_goog_testing_mockmatchers.js.source.html#line266">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>





  <a name="goog.testing.mockmatchers.isArray"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.mockmatchers.</span><span class="entryName">isArray</span>
        : <div class="fullType">(<span class="type"><a href="class_goog_testing_mockmatchers_ArgumentMatcher.html">goog.testing.mockmatchers.ArgumentMatcher</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span>)</div>
     </div>


     <div class="entryOverview">
       A matcher that verifies that an argument is an array.
     </div>

  </td>


  <td class="view-code">
     <a href="closure_goog_testing_mockmatchers.js.source.html#line274">Code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>





  <a name="goog.testing.mockmatchers.isArrayLike"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.mockmatchers.</span><span class="entryName">isArrayLike</span>
        : <div class="fullType">(<span class="type"><a href="class_goog_testing_mockmatchers_ArgumentMatcher.html">goog.testing.mockmatchers.ArgumentMatcher</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span>)</div>
     </div>


     <div class="entryOverview">
       A matcher that verifies that an argument is a array-like.  A NodeList is an
example of a collection that is very close to an array.
     </div>

  </td>


  <td class="view-code">
     <a href="closure_goog_testing_mockmatchers.js.source.html#line284">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>





  <a name="goog.testing.mockmatchers.isBoolean"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.mockmatchers.</span><span class="entryName">isBoolean</span>
        : <div class="fullType">(<span class="type"><a href="class_goog_testing_mockmatchers_ArgumentMatcher.html">goog.testing.mockmatchers.ArgumentMatcher</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span>)</div>
     </div>


     <div class="entryOverview">
       A matcher that verifies that an argument is a boolean.
     </div>

  </td>


  <td class="view-code">
     <a href="closure_goog_testing_mockmatchers.js.source.html#line311">Code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>





  <a name="goog.testing.mockmatchers.isDateLike"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.mockmatchers.</span><span class="entryName">isDateLike</span>
        : <div class="fullType">(<span class="type"><a href="class_goog_testing_mockmatchers_ArgumentMatcher.html">goog.testing.mockmatchers.ArgumentMatcher</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span>)</div>
     </div>


     <div class="entryOverview">
       A matcher that verifies that an argument is a date-like.
     </div>

  </td>


  <td class="view-code">
     <a href="closure_goog_testing_mockmatchers.js.source.html#line293">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>





  <a name="goog.testing.mockmatchers.isFunction"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.mockmatchers.</span><span class="entryName">isFunction</span>
        : <div class="fullType">(<span class="type"><a href="class_goog_testing_mockmatchers_ArgumentMatcher.html">goog.testing.mockmatchers.ArgumentMatcher</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span>)</div>
     </div>


     <div class="entryOverview">
       A matcher that verifies that an argument is a function.
     </div>

  </td>


  <td class="view-code">
     <a href="closure_goog_testing_mockmatchers.js.source.html#line329">Code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>





  <a name="goog.testing.mockmatchers.isNodeLike"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.mockmatchers.</span><span class="entryName">isNodeLike</span>
        : <div class="fullType">(<span class="type"><a href="class_goog_testing_mockmatchers_ArgumentMatcher.html">goog.testing.mockmatchers.ArgumentMatcher</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span>)</div>
     </div>


     <div class="entryOverview">
       A matcher that verifies that an argument is like a DOM node.
     </div>

  </td>


  <td class="view-code">
     <a href="closure_goog_testing_mockmatchers.js.source.html#line347">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>





  <a name="goog.testing.mockmatchers.isNumber"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.mockmatchers.</span><span class="entryName">isNumber</span>
        : <div class="fullType">(<span class="type"><a href="class_goog_testing_mockmatchers_ArgumentMatcher.html">goog.testing.mockmatchers.ArgumentMatcher</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span>)</div>
     </div>


     <div class="entryOverview">
       A matcher that verifies that an argument is a number.
     </div>

  </td>


  <td class="view-code">
     <a href="closure_goog_testing_mockmatchers.js.source.html#line320">Code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>





  <a name="goog.testing.mockmatchers.isObject"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.mockmatchers.</span><span class="entryName">isObject</span>
        : <div class="fullType">(<span class="type"><a href="class_goog_testing_mockmatchers_ArgumentMatcher.html">goog.testing.mockmatchers.ArgumentMatcher</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span>)</div>
     </div>


     <div class="entryOverview">
       A matcher that verifies that an argument is an object.
     </div>

  </td>


  <td class="view-code">
     <a href="closure_goog_testing_mockmatchers.js.source.html#line338">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>





  <a name="goog.testing.mockmatchers.isString"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.mockmatchers.</span><span class="entryName">isString</span>
        : <div class="fullType">(<span class="type"><a href="class_goog_testing_mockmatchers_ArgumentMatcher.html">goog.testing.mockmatchers.ArgumentMatcher</a></span><span>&nbsp;|&nbsp;</span><span class="type">null</span>)</div>
     </div>


     <div class="entryOverview">
       A matcher that verifies that an argument is a string.
     </div>

  </td>


  <td class="view-code">
     <a href="closure_goog_testing_mockmatchers.js.source.html#line302">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>



      <!-- Column 1 end -->
    </div>

        <div class="col2">
          <!-- Column 2 start -->
          <div class="col2-c">
            <h2 id="ref-head">Directory testing</h2>
            <div id="localView"></div>
          </div>

          <div class="col2-c">
            <h2 id="ref-head">File Reference</h2>
            <div id="sideFileIndex" rootPath="" current="testing/mockmatchers.js"></div>
          </div>
          <!-- Column 2 end -->
        </div>
</div>
</div>

</body>
</html>
